/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package my12306.bean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import my12306.table.KeyValueItem;

/**
 *
 * <pre>
 * <option value="9">商务座</option>
 * <option value="P">特等座</option>
 * <option value="M">一等座</option>
 * <option value="O">二等座</option>
 * <option value="6">高级软卧</option>
 * <option value="4">软卧</option>
 * <option value="3">硬卧</option>
 * <option value="2">软座</option>
 * <option value="1">硬座</option>
 * <option value="-1">无座</option>
 * <option value="7">一等软座</option>
 * <option value="8">二等软座</option>
 * </pre>
 *
 * @author Jack
 */
public class Seats {

    public final static KeyValueItem SeatBiz = new KeyValueItem("商务座", "9");
    public final static KeyValueItem SeatSpecialClass = new KeyValueItem("特等座", "P");
    public final static KeyValueItem SeatFirstClass = new KeyValueItem("一等座", "M");
    public final static KeyValueItem SeatSecondClass = new KeyValueItem("二等座", "O");
    public final static KeyValueItem SeatAdvSoftSpleeper = new KeyValueItem("高级软卧", "6");
    public final static KeyValueItem SeatSoftSleeper = new KeyValueItem("软卧", "4");
    public final static KeyValueItem SeatHardSleeper = new KeyValueItem("硬卧", "3");
    public final static KeyValueItem SeatSoft = new KeyValueItem("软座", "2");
    public final static KeyValueItem SeatHard = new KeyValueItem("硬座", "1");
    public final static KeyValueItem SeatNone = new KeyValueItem("无座", "-1");
    public final static KeyValueItem SeatFirstClassSoft = new KeyValueItem("一等软座", "7");
    public final static KeyValueItem SeatSecondClassSoft = new KeyValueItem("二等软座", "8");
    public final static HashMap<String, KeyValueItem> seats = new HashMap<String, KeyValueItem>();
    public final static List<KeyValueItem> seatList = new ArrayList<KeyValueItem>();

    static {
        seats.put(SeatAdvSoftSpleeper.getValue(), SeatAdvSoftSpleeper);
        seats.put(SeatBiz.getValue(), SeatBiz);
        seats.put(SeatFirstClass.getValue(), SeatFirstClass);
        seats.put(SeatHard.getValue(), SeatHard);
        seats.put(SeatHardSleeper.getValue(), SeatHardSleeper);
        seats.put(SeatNone.getValue(), SeatNone);
        seats.put(SeatSecondClass.getValue(), SeatSecondClass);
        seats.put(SeatSoft.getValue(), SeatSoft);
        seats.put(SeatSoftSleeper.getValue(), SeatSoftSleeper);
        seats.put(SeatSpecialClass.getValue(), SeatSpecialClass);
        seats.put(SeatFirstClassSoft.getValue(), SeatFirstClassSoft);
        seats.put(SeatSecondClassSoft.getValue(), SeatSecondClassSoft);
        seatList.add(SeatBiz);
        seatList.add(SeatSpecialClass);
        seatList.add(SeatFirstClass);
        seatList.add(SeatSecondClass);
        seatList.add(SeatAdvSoftSpleeper);
        seatList.add(SeatSoftSleeper);
        seatList.add(SeatHardSleeper);
        seatList.add(SeatSoft);
        seatList.add(SeatHard);
        seatList.add(SeatNone);
        seatList.add(SeatFirstClassSoft);
        seatList.add(SeatSecondClassSoft);
    }

    public static HashMap<String, KeyValueItem> allSeats() {
        return seats;
    }

    public static List<KeyValueItem> allSeatAsList() {
        return seatList;
    }

    /**
     * get the seat by seat type. if seat=9, return SeatBiz.
     *
     * @param seat
     * @return the seat.
     */
    public static KeyValueItem getSeat(String seat) {
        return seats.get(seat);
    }
}
